package com.fly.service;

import com.fly.domain.model.SysColumns;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author frinder
 * @date 2018/5/19
 * @className MySysColumnsService
 * @package com.fly.service
 * @Description: ${todo}
 */
@Service
public class MySysColumnsService {

    @Autowired
    private MyJdbcService myJdbcService;

    /**
     * @param tableName
     * @return
     */
    public List<SysColumns> getByTableName(String tableName) {
        String sql = "SELECT *\n" +
                "FROM sys_columns t\n" +
                "WHERE t.table_name = (:tableName)\n" +
                "ORDER BY t.sequence ASC";
        MapSqlParameterSource queryParameterSource = new MapSqlParameterSource("tableName", tableName);
        //
        return myJdbcService.queryList(SysColumns.class, sql, queryParameterSource);
    }

}
